import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from './router'
import store from './store'
import 'swiper/css';
import '@/assets/reset.css'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import * as echarts from 'echarts'
import china from '@/assets/json/china.json'; //导入china包
import { ref } from '@vue/reactivity'; // 导入 ref
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
createPinia().use(piniaPluginPersistedstate)
echarts.registerMap('china', china)
import './assets/iconfont/iconfont.css';
const app = createApp(App)
app.config.globalProperties.$echarts = (el) => {
    return echarts.init(el, null, { renderer: 'svg' })
}
app.use(createPinia()).use(router).use(ElementPlus).use(store)


// 将 echarts 添加到全局属性中
app.config.globalProperties.$echarts = echarts
// 自动将 Element Plus 中的所有图标组件注册为全局组件
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

app.provide('sharedState', {
    to: ref(''),
    setTo(to) {
      this.to.value = to;
    },
  });

app.mount('#app')

